home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Processes.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  7KB  |  255 lines

  1. /*
  2.      File:        Processes.h
  3.  
  4.      Contains:    Process Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __PROCESSES__
  19. #define __PROCESSES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __EVENTS__
  25. #include <Events.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30. #if FOR_SYSTEM8_PREEMPTIVE
  31. #ifndef __KERNEL__
  32. #include <Kernel.h>
  33. #endif
  34. #ifndef __FILEMANAGERTYPES__
  35. #include <FileManagerTypes.h>
  36. #endif
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT_SUPPORTED
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_ALIGN_SUPPORTED
  48. #pragma options align=mac68k
  49. #endif
  50.  
  51. /* type for unique process identifier */
  52. struct ProcessSerialNumber {
  53.     unsigned long                     highLongOfPSN;
  54.     unsigned long                     lowLongOfPSN;
  55. };
  56. typedef struct ProcessSerialNumber ProcessSerialNumber;
  57.  
  58. typedef ProcessSerialNumber *ProcessSerialNumberPtr;
  59.  
  60. enum {
  61.                                                                 /* Process identifier - Various reserved process serial numbers */
  62.     kNoProcess                    = 0,
  63.     kSystemProcess                = 1,
  64.     kCurrentProcess                = 2
  65. };
  66.  
  67. #if FOR_SYSTEM8_PREEMPTIVE
  68.  
  69. enum {
  70.                                                                 /* supported versions for GetApplicationInformation*/
  71.     kApplicationInformationVersion = 1
  72. };
  73.  
  74. struct ApplicationInformation {
  75.     TaskID                             primaryTaskID;
  76.     KernelProcessID                 applicationLauncher;
  77.     FSObjectRef                     applicationFile;
  78. };
  79. typedef struct ApplicationInformation ApplicationInformation;
  80.  
  81. typedef ApplicationInformation *ApplicationInformationPtr;
  82. extern OSStatus GetApplicationInformation(KernelProcessID theProcessID, PBVersion version, ApplicationInformation *appInfo);
  83.  
  84.  
  85. enum {
  86.                                                                 /* supported versions for LaunchInformation structure*/
  87.     kLaunchInformationVersion    = 1
  88. };
  89.  
  90. struct LaunchInformation {
  91.     KernelProcessID                 kernelProcessID;
  92. };
  93. typedef struct LaunchInformation LaunchInformation;
  94.  
  95. typedef LaunchInformation *LaunchInformationPtr;
  96. /* for now, the launch call only supports an application in the FSObjectSpecification*/
  97. extern OSStatus Launch(FSObjectRef theFSObjectRef, PBVersion version, LaunchInformation *launchInfo);
  98.  
  99. extern OSStatus GetKernelProcessIDFromPSN(const ProcessSerialNumber *PSN, KernelProcessID *kernelProcessID);
  100.  
  101. extern OSStatus GetPSNFromKernelProcessID(KernelProcessID kernelProcessID, ProcessSerialNumber *PSN);
  102.  
  103. #endif
  104. /* Definition of the parameter block passed to _Launch */
  105. /*
  106.  Typedef and flags for launchControlFlags field
  107.  #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED??
  108. */
  109. typedef unsigned short LaunchFlags;
  110.  
  111. enum {
  112.     launchContinue                = 0x4000,
  113.     launchNoFileFlags            = 0x0800,
  114.     launchUseMinimum            = 0x0400,
  115.     launchDontSwitch            = 0x0200,
  116.     launchAllow24Bit            = 0x0100,
  117.     launchInhibitDaemon            = 0x0080
  118. };
  119.  
  120. /*
  121.  Format for first AppleEvent to pass to new process.  The size of the overall
  122.   buffer variable: the message body immediately follows the messageLength 
  123. */
  124. struct AppParameters {
  125.     EventRecord                     theMsgEvent;
  126.     unsigned long                     eventRefCon;
  127.     unsigned long                     messageLength;
  128. };
  129. typedef struct AppParameters AppParameters;
  130.  
  131. typedef AppParameters *AppParametersPtr;
  132. /* Parameter block to _Launch */
  133. struct LaunchParamBlockRec {
  134.     unsigned long                     reserved1;
  135.     unsigned short                     reserved2;
  136.     unsigned short                     launchBlockID;
  137.     unsigned long                     launchEPBLength;
  138.     unsigned short                     launchFileFlags;
  139.     LaunchFlags                     launchControlFlags;
  140.     FSSpecPtr                         launchAppSpec;
  141.     ProcessSerialNumber             launchProcessSN;
  142.     unsigned long                     launchPreferredSize;
  143.     unsigned long                     launchMinimumSize;
  144.     unsigned long                     launchAvailableSize;
  145.     AppParametersPtr                 launchAppParameters;
  146. };
  147. typedef struct LaunchParamBlockRec LaunchParamBlockRec;
  148.  
  149. typedef LaunchParamBlockRec *LaunchPBPtr;
  150. /*
  151.  Set launchBlockID to extendedBlock to specify that extensions exist.
  152.  Set launchEPBLength to extendedBlockLen for compatibility.
  153. */
  154.  
  155. enum {
  156.     extendedBlock                = 0x4C43,                        /* 'LC' */
  157.     extendedBlockLen            = sizeof(LaunchParamBlockRec) - 12
  158. };
  159.  
  160.  
  161. enum {
  162.                                                                 /* Definition of the information block returned by GetProcessInformation */
  163.     modeLaunchDontSwitch        = 0x00040000,
  164.     modeDeskAccessory            = 0x00020000,
  165.     modeMultiLaunch                = 0x00010000,
  166.     modeNeedSuspendResume        = 0x00004000,
  167.     modeCanBackground            = 0x00001000,
  168.     modeDoesActivateOnFGSwitch    = 0x00000800,
  169.     modeOnlyBackground            = 0x00000400,
  170.     modeGetFrontClicks            = 0x00000200,
  171.     modeGetAppDiedMsg            = 0x00000100,
  172.     mode32BitCompatible            = 0x00000080,
  173.     modeHighLevelEventAware        = 0x00000040,
  174.     modeLocalAndRemoteHLEvents    = 0x00000020,
  175.     modeStationeryAware            = 0x00000010,
  176.     modeUseTextEditServices        = 0x00000008,
  177.     modeDisplayManagerAware        = 0x00000004
  178. };
  179.  
  180. /* Record returned by GetProcessInformation */
  181. struct ProcessInfoRec {
  182.     unsigned long                     processInfoLength;
  183.     StringPtr                         processName;
  184.     ProcessSerialNumber             processNumber;
  185.     unsigned long                     processType;
  186.     OSType                             processSignature;
  187.     unsigned long                     processMode;
  188.     Ptr                             processLocation;
  189.     unsigned long                     processSize;
  190.     unsigned long                     processFreeMem;
  191.     ProcessSerialNumber             processLauncher;
  192.     unsigned long                     processLaunchDate;
  193.     unsigned long                     processActiveTime;
  194.     FSSpecPtr                         processAppSpec;
  195. };
  196. typedef struct ProcessInfoRec ProcessInfoRec;
  197.  
  198. typedef ProcessInfoRec *ProcessInfoRecPtr;
  199. /* #endif // FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED??*/
  200. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  201.  
  202. #if GENERATING68K && !GENERATINGCFM
  203. #pragma parameter __D0 LaunchApplication(__A0)
  204. #endif
  205. extern pascal OSErr LaunchApplication(LaunchPBPtr LaunchParams)
  206.  ONEWORDINLINE(0xA9F2);
  207.  
  208. extern pascal OSErr LaunchDeskAccessory(const FSSpec *pFileSpec, ConstStr255Param pDAName)
  209.  THREEWORDINLINE(0x3F3C, 0x0036, 0xA88F);
  210.  
  211. extern pascal OSErr GetCurrentProcess(ProcessSerialNumber *PSN)
  212.  THREEWORDINLINE(0x3F3C, 0x0037, 0xA88F);
  213.  
  214. extern pascal OSErr GetFrontProcess(ProcessSerialNumber *PSN)
  215.  FIVEWORDINLINE(0x70FF, 0x2F00, 0x3F3C, 0x0039, 0xA88F);
  216.  
  217. extern pascal OSErr GetNextProcess(ProcessSerialNumber *PSN)
  218.  THREEWORDINLINE(0x3F3C, 0x0038, 0xA88F);
  219.  
  220. extern pascal OSErr GetProcessInformation(const ProcessSerialNumber *PSN, ProcessInfoRec *info)
  221.  THREEWORDINLINE(0x3F3C, 0x003A, 0xA88F);
  222.  
  223. extern pascal OSErr SetFrontProcess(const ProcessSerialNumber *PSN)
  224.  THREEWORDINLINE(0x3F3C, 0x003B, 0xA88F);
  225.  
  226. extern pascal OSErr WakeUpProcess(const ProcessSerialNumber *PSN)
  227.  THREEWORDINLINE(0x3F3C, 0x003C, 0xA88F);
  228.  
  229. extern pascal OSErr SameProcess(const ProcessSerialNumber *PSN1, const ProcessSerialNumber *PSN2, Boolean *result)
  230.  THREEWORDINLINE(0x3F3C, 0x003D, 0xA88F);
  231.  
  232. #endif
  233. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  234. #if !OLDROUTINELOCATIONS
  235. extern pascal void ExitToShell(void )
  236.  ONEWORDINLINE(0xA9F4);
  237.  
  238. #endif
  239. #endif
  240.  
  241. #if PRAGMA_ALIGN_SUPPORTED
  242. #pragma options align=reset
  243. #endif
  244.  
  245. #if PRAGMA_IMPORT_SUPPORTED
  246. #pragma import off
  247. #endif
  248.  
  249. #ifdef __cplusplus
  250. }
  251. #endif
  252.  
  253. #endif /* __PROCESSES__ */
  254.  
  255.